#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "euler087.in"

unsigned long long mpow (int n, int e) {
	if (e == 0) {
		return 1;
	} else if (e == 1) {
		return (unsigned long long)n;
	}
	return mpow ((unsigned long long)n, e - 1) * (unsigned long long)n;
}

int main () {
	int i, l, j, k;
	unsigned long long int s=0;
	l = sizeof (primes) / sizeof (primes[0]);
	for (i = 0; i < l; i++) {
		for (j = 0; j < l; j++) {
			s = 0;
			for (k = 0; k < l && s < 50000000; k++) {
				s = mpow (primes[i], 2) + mpow (primes[j], 3) + mpow (primes[k], 4);
				if (s < 50000000) {
					printf ("%llu\n", s);
				}
			}
		}
	}
	return 0;
}
